package cn.itsource.service.blog.imp;


import cn.itsource.blog.domain.comment.Comment;
import cn.itsource.mapper.repository.CommentRepository;
import cn.itsource.service.blog.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements ICommentService {

    @Autowired
    private CommentRepository repository;

    @Override
    public void add(Comment comment) {
        //id存在就是修改，不存在就是添加
        repository.save(comment);
    }
    @Override
    public void update(Comment comment) {
        repository.save(comment);
    }
    @Override
    public List<Comment> findByArticleId(Long articleId) {

        return repository.findByArticleId(articleId);
    }

    @Override
    public void delete(String id) {
        repository.deleteById(id);
    }
}
